<?php
class FacebookAlbum extends FacebookBase {
    
    private $_message;
    private $_name;
    private $_link;
    private $_count;
    private $_type;
    private $_comments;
    private $_photos;
    private $_from;
    private $_description;
    private $_privacy;
    private $_cover_photo;
    
    public function set_from(FacebookFrom $from) {
        $this->_from= $from;
        return $this;
    }
    
    public function get_from() {
        return $this->_from;
    }
    
    public function set_privacy($privacy) {
        $this->_privacy = $privacy;
        return $this;
    }
    
    public function get_privacy() {
        return $this->_privacy;
    }
    
    public function set_message($message) {
        $this->_message = $message;
        return $this;
    }
    
    public function get_message() {
        return $this->_message;
    }
    
    public function set_name($name) {
        $this->_name = $name;
        return $this;
    }
     
    public function get_name() {
        return $this->_name;
    }
    
    public function set_link($link) {
        $this->_link = $link;
        return $this;
    }
     
    public function get_link() {
        return $this->_link;
    }
    
    public function set_count($count) {
        $this->_count = $count;
        return $this;
    }
    
    public function get_count() {
        return $this->_count;
    }
    
    public function set_type($type) {
        $this->_type = $type;
        return $this;
    }
    
    public function get_type() {
        return $this->_type;
    }
    
    public function add_comment(FacebookComment $comment) {
        $this->_comments[] = $comment;
        return $this;
    }
    
    public function get_comments() {
        return $this->_comments;
    }
    
    public function get_comment($id) {
        foreach($this->_comments as $comment) {
            if($id == $comment->get_id()) {
                return $comment;
            }
        }
        return null;
    }
    
    public function add_photo(FacebookPhoto $photo) {
        $this->_photos[] = $photo;
        return $this;
    }
    
    public function get_photos() {
        return $this->_photos;
    }
    
    public function get_photo($id) {
        foreach($this->_photos as $photo) {
            if($id == $photo->get_id()) {
                return $photo;
            }
        }
        return null;
    }
    
    public function set_description($description) {
        $this->_description = $description;
        return $this;
    }
    
    public function get_description() {
        return $this->_description;
    }
    
    public function load_photos() {
        $lib = FB::get_instance();
        $rst = $lib->getPhotos($this->get_id());
        foreach ($rst->data as $p) {
            $this->_photos = FbFacade::factory('photo', $p);
        }
        
        return $this;
    }
    
    public function set_cover_photo($cover_id) {
        $this->_cover_photo = $cover_id;
        return $this;
    }
    
    public function get_cover_link() {
        if(NULL === $this->_cover_photo) {
            return NULL;
        }
        
        return FbFacade::get_album_cover_link($this->_cover_photo);
    }
}
